package com.lzw.d25bingso;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    private SharedPreferences sp ;
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Intent intent1 = new Intent(MainActivity.this,WelcomeActivity.class);
            Intent intent2 = new Intent(MainActivity.this,InfoActivity.class);
            if (sp.getBoolean("true",false)){
                startActivity(intent2);

            }else {
                startActivity(intent1);
                SharedPreferences.Editor editor = sp.edit();
                editor.putBoolean("true",true);
                editor.commit();

            }
            finish();
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        sp = getSharedPreferences("flag",MODE_PRIVATE);

        handler.sendEmptyMessageDelayed(1,2000);
    }
}
